package com.sunteam.flutter_oss_plugin

import com.alibaba.sdk.android.oss.ClientConfiguration
import com.alibaba.sdk.android.oss.common.OSSLog

object ConfigManager {
    fun buildConfig(
        userAgent: String,
        needLog: Boolean,
        needDns: Boolean,
        connectTimeOut: Int,
        socketTimeOut: Int,
        maxConcurrentNumber: Int,
        maxRetryNumber: Int
    ): ClientConfiguration {
        var conf = ClientConfiguration()
        conf?.run {
            connectionTimeout = connectTimeOut
            maxConcurrentRequest = maxConcurrentNumber
            maxErrorRetry = maxRetryNumber
            socketTimeout = socketTimeOut
        }
        conf.isHttpDnsEnable = needDns
        if (needLog) {
            OSSLog.enableLog()
        }
        if (userAgent.isNotEmpty()) {
            conf.setUserAgentMark(userAgent)
        }
        return conf
    }
}